package
{
	import flash.display.Bitmap;
	import flash.utils.Dictionary;
	
	import starling.textures.Texture;
	import starling.textures.TextureAtlas;
	
	public class Assets
	{
		
		// Embed the Atlas XML
		[Embed(source="../assets/cucaracha.xml", mimeType="application/octet-stream")]
		public static const cucarachaXml:Class;
		
		// Embed the Atlas Texture:
		[Embed(source="../assets/cucaracha.png")]
		public static const cucarachaTexture:Class;
		
		
		private static var gameTextures:Dictionary=new Dictionary();
		
		
		public  function getAtlas(name:String):TextureAtlas{
			
			if(gameTextures[name] == undefined){
				
				var xml:XML = XML(new Assets[name+'Xml']());
				var texture:Texture = Texture.fromBitmap(new Assets[name+'Texture']());
				//Assets[name] =new TextureAtlas(texture,xml);
				gameTextures[name] = new TextureAtlas(texture,xml);
			}
			return gameTextures[name];
		}
		
		public static function getTexture(name:String):Texture{
			
			if(gameTextures[name] == undefined){
				
				var bitmap:Bitmap=new Assets[name]();
				gameTextures[name] = Texture.fromBitmap(bitmap);
			}
			
			return gameTextures[name];
			
		}
	}
}